// Copyright 2007 the original author or authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package lichen.pages.control.friendList;

import lichen.entities.user.FriendList;
import lichen.pages.Operations;
import lichen.pages.base.AbstractControlPage;
import lichen.services.UserService;

import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.Inject;
import org.apache.tapestry.corelib.components.Loop;
import org.apache.tapestry.corelib.components.PageLink;


/**
 * 好友列表显示
 * @author <a href=mailto:xiafei114@gmail.com>xiafei114</a>
 * @version $Revision$
 * @since 0.0.3
 */
public class ViewFriendList extends AbstractControlPage{
	
//	新建主题的链接
	@SuppressWarnings("unused")
	@Component(parameters = {"page=control/friendList/form","context=newActionParameters"})
	private PageLink newFriendListLink;
	
	
//	编辑主题的链接
	@SuppressWarnings("unused")
	@Component(parameters = {"page=control/friendList/form","context=editActionParameters"})
	private PageLink editFriendListLink;
	
	@SuppressWarnings("unused")
	@Component(parameters = { "source=user.friendLists", "value=friendList" })
	private Loop friendListLoop;
	
	@Inject
	private UserService _userService;
	
	/**
	 * 删除.
	 * @param forumId 论坛的ID.
	 */
	void onActionFromDeleteLink(FriendList friendList) {
		this.getEntityService().delete(friendList);
	}
	
	/**
	 * 当前好友
	 */
	private FriendList friendList;
	
	/**
	 * 得到新增帖子的参数
	 * @return 新建帖子时候的参数.
	 */
	public Object[] getNewActionParameters(){
		return new Object[]{Operations.NEW,this.getUser()};
	}
	
	/**
	 * 得到编辑帖子的参数
	 * @return 编辑帖子时候的参数.
	 */
	public Object[] getEditActionParameters(){
		return new Object[]{Operations.EDIT,this.friendList};
	}

	/**
	 * @return Returns the friendList.
	 */
	public FriendList getFriendList() {
		return friendList;
	}

	/**
	 * @param friendList The friendList to set.
	 */
	public void setFriendList(FriendList friendList) {
		this.friendList = friendList;
	}
}
